#@Author: bjy @Date: 2019/5/8 9:36 @Version 1.0#
<template>
  <div class="main-div">
      <el-col :span="6">
        <div class="tree">
          <el-tabs type="border-card">
            <el-tab-pane label="组织结构">
              <el-tree :data="data"
                       :props="defaultProps"
                       @node-click="nodeClick"
                       current-node-key
                       default-expand-all
                       highlight-current
                       style="overflow:auto;height: 600px;">
              </el-tree>
            </el-tab-pane>
          </el-tabs>
        </div>
      </el-col>
  </div>
</template>
<script>
    //  此处导入组件,格式,例如:import xxx名称 from "路径"
    export default{
        // 这里是name,记得填写
        name: 'navTree',
      props:[],
        //  数据定义
        data () {
            return {
              data: [],
              defaultProps: {
                children: 'child',
                label: 'showName'
              },
              currentNode:{},
            }
        },
        created(){
          this.$http({
            url: this.$BASE_URL+'api/dept/findAllTree',
            headers:{
              token:sessionStorage.getItem("token")
            },
          }).then((res)=>{
            if(res.data.code == 200){
              this.data = res.data.output;
            }
          },(res)=>{
            this.$notify.error({
              title: '错误',
              message: "服务器连接故障！",
              duration: 5000
            });
          });
        },
        // 页面方法
        methods: {
          nodeClick(data, node, vuecomponen){
            this.currentNode = data;
            data['parentData'] = node.parent.data;
            this.$emit('changeThisDept',data)
          }
        },
        // 计算属性
        computed: {},
        // 侦听器
        watch: {},
        // 依赖注入
        components: {}
    }
</script>

<!-- 本地样式 -->
<style scoped>
  .main-div{
    width: 100%;
    height: 100%;
    margin-top: 10px;
  }
  .tree{
    min-width: 350px;
  }
</style>
